home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8242 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  10.3 KB

  1. Path: ix.netcom.com!netnews
  2. From: jatco@ix.netcom.com (jatco)
  3. Newsgroups: comp.lang.c++
  4. Subject: The JTC NEWS LETTER - A Forum For IDAPI Developers
  5. Date: Fri, 16 Feb 1996 04:14:10 GMT
  6. Organization: Netcom
  7. Message-ID: <4g0lr6$e06@cloner2.ix.netcom.com>
  8. NNTP-Posting-Host: ix-nyc14-09.ix.netcom.com
  9. X-NETCOM-Date: Thu Feb 15  5:15:18 PM PST 1996
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. ----------------------------------------------------------------------
  13.    _______ _______  _____                      February 15, 1996
  14.   |__   __|__   __ / ____|      ___     __
  15.      | |     | |  | |          / _ \   / /______   __  ________
  16.   _  | |     | |  | |         / / \ \ / / ___/\ \ /  \ / / ___/
  17.  | |_| |     | |  | |____    / /   \ / / /__/  \ / /\ / (__  )  Letter
  18.   \____|     |_|   \_____|  /_/     \_/____/    \_/  \_/____/
  19.      Jatco Tec. Corp.             Volume 1, Number 1
  20. ----------------------------------------------------------------------
  21.  
  22.  
  23. Highlights include:
  24.  
  25.      o The JTC NEWS LETTER - A Forum For IDAPI Developers
  26.      o How To Subscribe To The JTC NEWS LETTER
  27.      o How To Contribute Content To The JTC NEWS LETTER
  28.      o Thumbs Up For IDAPI And The BDE
  29.      o Getting Down To Business - Differences Between IDAPI Versions
  30.      o A Final Word
  31.  
  32.  
  33. The JTC NEWS LETTER - A Forum For IDAPI Developers
  34. +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-
  35.  
  36. As you may know, JTC developed Jatco OIL(TM), a commercialy available 
  37. C++ class library for IDAPI, to support C++ developers using the 
  38. Borland Database Engine and IDAPI in their database development. Our 
  39. customers tell us it is a great product and, through their feedback 
  40. and suggestions, have helped us to make it an even better product. We 
  41. thought it would be a good idea to provide a common space where we 
  42. could publish some of the experiences, suggestions, comments, and 
  43. ideas that our customers, and for that matter all IDAPI developers 
  44. (whether or not you are using Jatco OIL) have to share. Therefor, we 
  45. decided to put together this newsletter so that we could share some 
  46. of this information with you. But we can't do it alone. We need you 
  47. to contribute and share with your fellow developers your own 
  48. experiences developing with the BDE, IDAPI and OIL. Your 
  49. contributions can be anything from a code snipit to an article.
  50.  
  51.  
  52. How To Subscribe To The JTC NEWS LETTER
  53. +--+--+--+--+--+--+--+--+--+--+--+--+--
  54.  
  55. If you would like to subscribe and receive future editions of the JTC 
  56. NEWS LETTER then email us at jatco@ix.netcom.com. Include the text 
  57. "SUBSCRIBE" in the body of the email and we will then put you on our 
  58. email distribution list.
  59.  
  60.  
  61. How To Contribute Content To The JTC NEW LETTER
  62. +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-
  63.  
  64. To contribute content to the newsletter send it to us at our email 
  65. address at jatco@ix.netcom.com. Include your name, company name, 
  66. email address and the text "CONTRIBUTE CONTENT" in the body of the 
  67. email. We are investigating alternate methods of providing content 
  68. for the future but for now we will only accept content as ASCII text.
  69.  
  70. If you are providing code samples along with your content, we will 
  71. accept C, C++ and Delphi Pascal in native IDAPI and OIL. Also, try to 
  72. keep the code samples as small and as concise as possible.
  73.  
  74. Pleas note that we do reserve the right to edit all content.
  75.  
  76.  
  77. Thumbs Up For IDAPI And The BDE
  78. +--+--+--+--+--+--+--+--+--+--+
  79.  
  80. You have spent weeks, maybe months, getting your program's screens 
  81. and graphics to look just right. Now, all that is left to be done is 
  82. to throw in some code to connect your program to its data, right? 
  83. Wrong!
  84.  
  85. No one said it was going to be easy. Database programming can be a 
  86. real pain. First, you have to decide if your app will use 
  87. client/server, network/multi-user, or a local database architecture. 
  88. Then you have to decide which database format you want to use - dBASE 
  89. or Paradox if you go local or network/multi-user, Sybase, MS SQL 
  90. Server, Oracle, Informix or Interbase if you go client/server. 
  91. Lastly, you have to decide between using the native api (like dblib) 
  92. supplied by the database vendor to access your data or if you will 
  93. opt for a layer of insulation and use either ODBC or IDAPI.
  94.  
  95. There is a lot to be said for opting to insulate your applications 
  96. from a specific vendor's api. For one thing, choosing to code to the 
  97. vendor's api obviously locks you into their database product. It also 
  98. makes moving to a different architecture somewhere down the road 
  99. (moving from network/multi-user to client/server for example) a major 
  100. rewrite of your application. Using heterogeneous databases in one 
  101. application would mean you would have to use two different apis in 
  102. the same program.
  103.  
  104. So what is a good programmer to do? Our experience has shown us that 
  105. the more you insulate yourselves from a specific vendor's product and 
  106. api the happier you and your customers will be. Unless you are 
  107. developing a real-time, extremely high volume transaction oriented 
  108. system, using a layer of abstraction is your smartest choice.
  109.  
  110. But which abstraction layer should you chose, ODBC or IDAPI? If you 
  111. are using dBASE of Paradox, go with IDAPI because its native drivers 
  112. are the same ones used by Borland in their dBASE and Paradox for 
  113. Windows products. Also, because IDAPI is also ODBC compliant it 
  114. therefore can use any ODBC driver.
  115.  
  116. We believe, from our own experience, that IDAPI is also a better 
  117. choice over ODBC if you are developing a client/server based app 
  118. because IDAPI's native api also supports pass-through SQL allowing 
  119. you to bypass IDAPI altogether when querying for data. Mixing ANSI 
  120. SQL with IDAPI's strong navigational api provides a powerful command 
  121. set at your disposal.
  122.  
  123.  
  124. Getting Down To Business - Differences between IDAPI versions
  125. +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  126.  
  127. Borland first introduced the IDAPI sdk with its Database Tools for 
  128. the BC++ V4.0. Since this initial release, both Delphi and BC++ V4.5 
  129. shipped with an updated version of the BDE.
  130.  
  131. From our own experiences, we have found some interesting differences 
  132. between these versions and we thought we would pass them on to you so 
  133. that you won't trip over them. We also have some suggestions as to 
  134. how to avoid some of these trip-wires so that your apps won't be 
  135. impacted by changes in these and future versions of the BDE.
  136.  
  137.  
  138. Database Table Names In Query Statements
  139. ----------------------------------------
  140.  
  141. In the version of the IDAPI sdk that shipped with BC++ V4.0 you were 
  142. able to omit the table name qualifier in a query statement and the 
  143. BDE accepted it without it. However, with the version of the BDE that 
  144. shipped with Delphi and BC++ V4.5 this isn't the case. The following 
  145. code, which uses the Jatco OIL C++ IDAPI class library, demonstrates 
  146. the problem:
  147.  
  148.    const char * sql = "SELECT * FROM AUTO";
  149.    pStatement stmt = new Statement((pCHAR)sql, qrylangSQL);
  150.    pQuery qry = new Query(*stmt, *ptheAutoLogDatabase);
  151.    qry->xDbiQExecDirect();
  152.  
  153. The above works with the version of the BDE that shipped with BC++ 
  154. V4.0 and BC++ V4.5, but it doesn't work with the version that shiped 
  155. with Delphi V1.0.
  156.  
  157. The solution to this problem is to include the table name qualifier 
  158. and code it as the following:
  159.  
  160.    const char * sql = "SELECT * FROM \"AUTO.DB\"";
  161.    pStatement stmt = new Statement((pCHAR)sql, qrylangSQL);
  162.    pQuery qry = new Query(*stmt, *ptheAutoLogDatabase);
  163.    qry->xDbiQExecDirect();
  164.  
  165.  
  166. Result Column Names Returned For Aggregates Functions
  167. -----------------------------------------------------
  168.  
  169. Jatco OIL allows you to read and write values from a cursor's record 
  170. buffer using the name of the column as an identifier. It seems that 
  171. Borland changed the column names for aggregate values (aggregate 
  172. values are the values that are returned by the aggregate functions 
  173. SUM, AVG, MIN, MAX AND COUNT) returned from a query in its newer 
  174. version of the BDE (Delphi, BC++ V4.5). In the previous version of 
  175. the BDE the column name returned for the aggregate COUNT(Id) on a 
  176. local table was "Count of Id". Not so in the newer version of the 
  177. BDE. The following code, which uses the Jatco OIL C++ IDAPI class 
  178. library, demonstrates the problem:
  179.  
  180.    const char *sql =
  181.          "SELECT COUNT(Id) FROM \"AUTO.DB\" A WHERE A.ALIAS = \"%s\"";
  182.    sprintf(szBuffer, sql, szAlias);
  183.    pStatement stmt = new Statement((pCHAR)szBuffer, qrylangSQL);
  184.    pQuery qry = new Query(*stmt, *ptheAutoLogDatabase);
  185.    qry->xDbiQExecDirect();
  186.    qry->ResultCur()->SetupCursor();
  187.    qry->ResultCur()->xDbiGetNextRecord();
  188.    FLOAT count = 0;
  189.    qry->ResultCur()->xDbiGetField("Count of Id",(pBYTE)&count);
  190.  
  191. The above works with the version of the BDE that shipped with BC++ 
  192. V4.0 and BC++ V4.5, but it doesn't work with the version that shiped 
  193. with Delphi V1.0.
  194.  
  195. The solution is that, rather than hard coding the column name in the 
  196. Cursor method xDbiGetField, use the overloaded version of this method 
  197. that takes an ordinal number for the column you want to read and a 
  198. pointer to the record buffer. This frees you from having to know the 
  199. column names of aggregate values. The following code demonstrates the 
  200. better way to deal with returned aggregate values:
  201.  
  202.    const char *sql =
  203.         "SELECT COUNT(Id) FROM \"AUTO.DB\" A WHERE A.ALIAS = \"%s\"";
  204.    sprintf(szBuffer, sql, szAlias);
  205.    pStatement stmt = new Statement((pCHAR)szBuffer, qrylangSQL);
  206.    pQuery qry = new Query(*stmt, *ptheAutoLogDatabase);
  207.    qry->xDbiQExecDirect();
  208.    qry->ResultCur()->SetupCursor();
  209.    qry->ResultCur()->xDbiGetNextRecord();
  210.    FLOAT count = 0;
  211.    qry->ResultCur()->xDbiGetField(1, qry->ResultCur()->RecBuf(),
  212.          (pBYTE)&count);
  213.  
  214.  
  215. A Final Word
  216. +--+--+--+--
  217.  
  218. Now that Borland has announcded Delphi 2.0 and Borland C++ for Win96 
  219. and WinNT we hope to cover the 32 bit version of the BDE/IDAPI in 
  220. future issues of The JTC NEWS LETTER. We would like to hear your 
  221. ideas and comments. Email us at jatco@ix.netcom.com.
  222.  
  223. For information about Jatco OIL(TM) (Object IDAPI Library), our 
  224. commercial C++ class library for IDAPI, you can contact us by email 
  225. at jatco@ix.netcom.com or by phone at 718 445-2235 between the hours 
  226. of 9a and 5p, Monday through Friday, eastern standard time.
  227.  
  228. Thanks for spending some time with us and we look forward to your 
  229. joining us in making The JTC NEWS LETTER a forum for all IDAPI 
  230. developers.
  231.  
  232. ----------------------------------------------------------------------
  233. End JTC NEWS LETTER 1.1                                     2/15/96
  234. ----------------------------------------------------------------------
  235.  
  236.